Handle case where path to config.core.php includes symlinks.#20
Open
graphiclunarkid wants to merge 1 commit intob03tz:masterfrom
Open
Handle case where path to config.core.php includes symlinks.#20graphiclunarkid wants to merge 1 commit intob03tz:masterfrom
graphiclunarkid wants to merge 1 commit intob03tz:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
connector.phpcurrently uses the PHP magic constant__FILE__to specify the current directory and then traverses up using thedirname()function to locateconfig.core.php.Our installation of MODX revolution has its resources directory outside the core directory, and includes it via a symlink instead, with the installation directory being
/srv/modx/revolution/$ ls -l /srv/modx/revolution/includes the following lines:... lrwxrwxrwx 1 apache apache 9 Feb 16 17:00 assets -> ../assets ... -rw-r--r-- 1 apache apache 101 Mar 19 15:15 config.core.php ...Since PHP 4.0.2,
__FILE__always contains an absolute path with symlinks resolved.In our particular case
__FILE__resolves to/srv/modx/assets/components/formsave.config.core.phpis found nowhere on that path (it's in/srv/modx/revolution/) soconnector.phpfails when trying to open the "view stored forms" component in MODX manager. The following message appears in the apache error log:[Sat Apr 12 18:48:58 2014] [error] [client <IP address removed>] PHP Fatal error: require_once(): Failed opening required '/srv/config.core.php' (include_path='.:/usr/share/pear:/usr/share/php') in /srv/modx/assets/components/formsave/connector.php.new on line 32, referer: <removed>A possible work-around is to copy
/srv/modx/revolution/config.core.phpto/srv/config.core.php.This patch replaces the use of
__FILE__with$_SERVER["SCRIPT_FILENAME"]as suggested in this StackOverflow question. I've tested this on MODX Revolution 2.2.13-pl (git) and it works without having to resort to copying config.core.php.Fixes #19